﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBControl;
using System.Data;

namespace ZSZK
{
    public partial class sublogincheck : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["subindex"] != null)
            {
                string loginsubindex = Request.QueryString["subindex"];
                SqlDbHelper sdh = new SqlDbHelper();
                string getsubuser = "SELECT * FROM UserSession WHERE loginsubindex = '" + loginsubindex + "'";
                DataTable dt = sdh.ExecuteDataTable(getsubuser);
                if (dt.Rows.Count == 0)
                {
                    Response.Redirect("/ksgj/404.htm");
                }
                else
                {
                    DateTime subdate = DateTime.Parse(dt.Rows[0]["UpdateTime"].ToString());
                    if (subdate.CompareTo(DateTime.Now.Date) < 0)
                    {
                        Response.Redirect("/ksgj/404.htm");
                    }
                    else
                    {
                        string subnick = dt.Rows[0]["UsNick"].ToString();
                        string parentnick = dt.Rows[0]["ParentNick"].ToString();
                        string sessinokey = dt.Rows[0]["SessionKey"].ToString();
                        string subid = dt.Rows[0]["UsID"].ToString();
                        Session.Add("subUserNick", subnick);
                        Session.Add("ParentusNick", parentnick);
                        Session.Add("ParentsessionKey", sessinokey);
                        Session.Add("subid", subid);
                        Session.Timeout = 1;
                        //Response.Redirect("subindex.aspx");
                        Response.Redirect("/ksgj/subindex.aspx");

                    }
                }
            }
            else
            {
                Response.Redirect("/ksgj/404.htm");
            }

        }
    }
}